﻿using PLCTest.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PLCTest.BO
{
    public class ZJNScMessageWriteWcsActionBO
    {
        /// <summary>
        /// 启动命令
        /// </summary>
        public bool Startcommand { get; set; }
        /// <summary>
        /// 报警复位
        /// </summary>
        public bool Alarmreset { get; set; }
        /// <summary>
        /// 自动任务复位
        /// </summary>
        public bool Taskreset { get; set; }
        /// <summary>
        /// WCS消防命令
        /// </summary>
        public bool WCSfirecommand { get; set; }

        /// <summary>
        /// WCS拍照温度无异常
        /// </summary>
        public bool WCSPhotoFire { get; set; }

        /// <summary>
        /// WCS拍照温度异常堆垛机救火
        /// </summary>
        public bool WCSRgvFireHlper { get; set; }

        /// <summary>
        /// DTS有温度报警但红外摄像仪拍照无异常，请人工检查
        /// </summary>
        public bool WCSDTSAlarm { get; set; }

        /// <summary>
        /// WCS时间复位
        /// </summary>
        public bool TimeReset { get; set; }

        /// <summary>
        /// 工作序号
        /// </summary>
        public int Jobnumber { get; set; }
        /// <summary>
        /// 工作命令代码 
        /// </summary>
        public short Jobordercode { get; set; }
        /// <summary>
        /// 启始行fromPC
        /// </summary>
        public short StartlinefromPC { get; set; }
        /// <summary>
        /// 启始列fromPC
        /// </summary>
        public short StartcolumnfromPC { get; set; }
        /// <summary>
        /// 启始层fromPC
        /// </summary>
        public short StartlayerfromPC { get; set; }
        /// <summary>
        /// 目标行fromPC
        /// </summary>
        public short TargetlinefromPC { get; set; }
        /// <summary>
        /// 目标列fromPC
        /// </summary>
        public short TargetcolumnfromPC { get; set; }
        /// <summary>
        /// 目标层fromPC
        /// </summary>
        public short TargetlayerfromPC { get; set; }
        /// <summary>
        /// WCS过账完成
        /// </summary>
        public short WCSpostingcompleted { get; set; }
        /// <summary>
        /// 托盘类型 1：大托盘   2：小托盘
        /// </summary>
        public short yuliu8 { get; set; }
        public short yuliu9 { get; set; }
        public short yuliu10 { get; set; }
        public short yuliu11 { get; set; }
        public short yuliu12 { get; set; }

        /// <summary>
        /// RGV-PC消防水箱处请求放料
        /// </summary>
        public bool RgvRequsetPush { get; set; }
        /// <summary>
        /// RGV-PC消防水箱处放料完成
        /// </summary>
        public bool RgvPushFinish { get; set; }
        /// <summary>
        /// PC-RGV消防水箱处允许放料
        /// </summary>
        public bool RgvCanPush { get; set; }
        /// <summary>
        /// 开机时间
        /// </summary>
        public int StartTime { get; set; }
        /// <summary>
        /// 手动时间
        /// </summary>
        public int HandTime { get; set; }
        /// <summary>
        /// 手动故障时间
        /// </summary>
        public int HandHitchTime { get; set; }
        /// <summary>
        /// 自动运行时间
        /// </summary>
        public int AutoRuningTime { get; set; }
        /// <summary>
        /// 自动待机时间
        /// </summary>
        public int AutoWaitingTime { get; set; }
        /// <summary>
        /// 自动故障时间
        /// </summary>
        public int AutoHitchTime { get; set; }
        /// <summary>
        /// 任务运行时间
        /// </summary>
        public int TaskRuningTime { get; set; }




        public byte[] Deserialize()
        {
            byte[] bytes = new byte[62];
            HelperByte.SetBitAt(ref bytes, 0, 0, Startcommand);
            HelperByte.SetBitAt(ref bytes, 0, 1, Alarmreset);
            HelperByte.SetBitAt(ref bytes, 0, 2, Taskreset);
            HelperByte.SetBitAt(ref bytes, 0, 3, WCSfirecommand);
            HelperByte.SetBitAt(ref bytes, 0, 4, WCSPhotoFire);
            HelperByte.SetBitAt(ref bytes, 0, 5, WCSRgvFireHlper);
            HelperByte.SetBitAt(ref bytes, 0, 6, WCSDTSAlarm);
            HelperByte.SetBitAt(ref bytes, 0, 7, TimeReset);
            HelperByte.SetDIntAt(bytes, 2, Jobnumber);
            HelperByte.SetIntAt(bytes, 6, Jobordercode);
            HelperByte.SetIntAt(bytes, 8, StartlinefromPC);
            HelperByte.SetIntAt(bytes, 10, StartcolumnfromPC);
            HelperByte.SetIntAt(bytes, 12, StartlayerfromPC);
            HelperByte.SetIntAt(bytes, 14, TargetlinefromPC);
            HelperByte.SetIntAt(bytes, 16, TargetcolumnfromPC);
            HelperByte.SetIntAt(bytes, 18, TargetlayerfromPC);
            HelperByte.SetIntAt(bytes, 20, WCSpostingcompleted);
            HelperByte.SetIntAt(bytes, 22, yuliu8);
            HelperByte.SetIntAt(bytes, 24, yuliu9);
            HelperByte.SetIntAt(bytes, 26, yuliu10);
            HelperByte.SetIntAt(bytes, 28, yuliu11);
            HelperByte.SetIntAt(bytes, 30, yuliu12);
            HelperByte.SetBitAt(ref bytes, 32, 0, RgvRequsetPush);
            HelperByte.SetBitAt(ref bytes, 32, 1, RgvPushFinish);
            HelperByte.SetBitAt(ref bytes, 32, 2, RgvCanPush);
            HelperByte.SetDIntAt(bytes, 34, StartTime);
            HelperByte.SetDIntAt(bytes, 38, HandTime);
            HelperByte.SetDIntAt(bytes, 42, HandHitchTime);
            HelperByte.SetDIntAt(bytes, 46, AutoRuningTime);
            HelperByte.SetDIntAt(bytes, 50, AutoWaitingTime);
            HelperByte.SetDIntAt(bytes, 54, AutoHitchTime);
            HelperByte.SetDIntAt(bytes, 58, TaskRuningTime);
            return bytes;
        }
    }
}
